home *** CD-ROM | disk | FTP | other *** search
/ Motor Sport Digital Archive Collection 1960s / Motor Sport Digital Archive Collection 1960s.iso / main.swf / scripts / views / SearchTab.as < prev    next >
Encoding:
Text File  |  2008-05-21  |  35.4 KB  |  1,024 lines

  1. package views
  2. {
  3.    import com.glenpike.search.TextFileSearcher;
  4.    import events.NavigationEvent;
  5.    import events.SearchEvent;
  6.    import flash.accessibility.*;
  7.    import flash.debugger.*;
  8.    import flash.display.*;
  9.    import flash.errors.*;
  10.    import flash.events.*;
  11.    import flash.external.*;
  12.    import flash.filters.*;
  13.    import flash.geom.*;
  14.    import flash.media.*;
  15.    import flash.net.*;
  16.    import flash.printing.*;
  17.    import flash.profiler.*;
  18.    import flash.system.*;
  19.    import flash.text.*;
  20.    import flash.ui.*;
  21.    import flash.utils.*;
  22.    import flash.xml.*;
  23.    import model.PresentationModel;
  24.    import mx.binding.*;
  25.    import mx.collections.ArrayCollection;
  26.    import mx.containers.Canvas;
  27.    import mx.containers.VBox;
  28.    import mx.controls.Alert;
  29.    import mx.controls.Button;
  30.    import mx.controls.Image;
  31.    import mx.controls.ProgressBar;
  32.    import mx.controls.RadioButton;
  33.    import mx.controls.Text;
  34.    import mx.controls.TextInput;
  35.    import mx.core.Repeater;
  36.    import mx.core.UIComponentDescriptor;
  37.    import mx.core.mx_internal;
  38.    import mx.events.FlexEvent;
  39.    import mx.events.PropertyChangeEvent;
  40.    import mx.styles.*;
  41.    
  42.    public class SearchTab extends Canvas
  43.    {
  44.       private static var _watcherSetupUtil:IWatcherSetupUtil;
  45.       
  46.       [Bindable]
  47.       private var _1057894073resultsCount:Text;
  48.       
  49.       private var _bindings:Array;
  50.       
  51.       private var searchMode:String = "magazine";
  52.       
  53.       [Bindable]
  54.       private var _710473164searchTerm:String = "";
  55.       
  56.       private var txtSearch:TextFileSearcher;
  57.       
  58.       public var _bindingsByDestination:Object;
  59.       
  60.       [Bindable]
  61.       private var _1412401219rptText:Array;
  62.       
  63.       private var dir:String = "data/text/";
  64.       
  65.       [Bindable]
  66.       private var _1001078227progress:ProgressBar;
  67.       
  68.       [Bindable]
  69.       private var _1778179843searchBox:VBox;
  70.       
  71.       [Bindable]
  72.       private var _1493698498_VBox2:VBox;
  73.       
  74.       private var _embed_mxml____embedded_assets_search_tab_bg_png_2045520245:Class;
  75.       
  76.       [Bindable]
  77.       private var _1778195246searchRpt:Repeater;
  78.       
  79.       public var _bindingsBeginWithWord:Object;
  80.       
  81.       private var ext:String = ".txt";
  82.       
  83.       [Bindable]
  84.       private var _1857328081presentationModel:PresentationModel;
  85.       
  86.       private var currentResult:int = 0;
  87.       
  88.       [Bindable]
  89.       private var _476548482cancelBtn:Button;
  90.       
  91.       [Bindable]
  92.       private var _682052866searchTxtInput:TextInput;
  93.       
  94.       [Bindable]
  95.       private var _973070101searchInArchive:RadioButton;
  96.       
  97.       [Bindable]
  98.       private var _744247857searchingBox:VBox;
  99.       
  100.       private var _watchers:Array;
  101.       
  102.       [Bindable]
  103.       private var _1880932050searchResults:ArrayCollection;
  104.       
  105.       [Bindable]
  106.       private var _559758042searchInMag:RadioButton;
  107.       
  108.       private var _documentDescriptor_:UIComponentDescriptor;
  109.       
  110.       public function SearchTab()
  111.       {
  112.          _documentDescriptor_ = new UIComponentDescriptor({
  113.             "type":Canvas,
  114.             "propertiesFactory":function():Object
  115.             {
  116.                return {
  117.                   "width":206,
  118.                   "height":926,
  119.                   "childDescriptors":[new UIComponentDescriptor({
  120.                      "type":Image,
  121.                      "propertiesFactory":function():Object
  122.                      {
  123.                         return {
  124.                            "source":_embed_mxml____embedded_assets_search_tab_bg_png_2045520245,
  125.                            "width":206,
  126.                            "height":926
  127.                         };
  128.                      }
  129.                   }),new UIComponentDescriptor({
  130.                      "type":VBox,
  131.                      "id":"searchBox",
  132.                      "propertiesFactory":function():Object
  133.                      {
  134.                         return {
  135.                            "x":6,
  136.                            "y":48,
  137.                            "horizontalScrollPolicy":"off",
  138.                            "verticalScrollPolicy":"off",
  139.                            "childDescriptors":[new UIComponentDescriptor({
  140.                               "type":Text,
  141.                               "propertiesFactory":function():Object
  142.                               {
  143.                                  return {
  144.                                     "text":"What word or phrase would you like to search for?",
  145.                                     "width":160
  146.                                  };
  147.                               }
  148.                            }),new UIComponentDescriptor({
  149.                               "type":TextInput,
  150.                               "id":"searchTxtInput",
  151.                               "events":{
  152.                                  "focusIn":"__searchTxtInput_focusIn",
  153.                                  "focusOut":"__searchTxtInput_focusOut"
  154.                               },
  155.                               "propertiesFactory":function():Object
  156.                               {
  157.                                  return {
  158.                                     "styleName":"searchTxtInput",
  159.                                     "text":"search for...",
  160.                                     "toolTip":"Enter your search terms here"
  161.                                  };
  162.                               }
  163.                            }),new UIComponentDescriptor({
  164.                               "type":Text,
  165.                               "propertiesFactory":function():Object
  166.                               {
  167.                                  return {
  168.                                     "text":"Where would you like to search?",
  169.                                     "width":160
  170.                                  };
  171.                               }
  172.                            }),new UIComponentDescriptor({
  173.                               "type":RadioButton,
  174.                               "id":"searchInMag",
  175.                               "events":{"click":"__searchInMag_click"},
  176.                               "propertiesFactory":function():Object
  177.                               {
  178.                                  return {
  179.                                     "buttonMode":true,
  180.                                     "styleName":"searchRadioButton",
  181.                                     "label":"In the current magazine",
  182.                                     "groupName":"searchgroup",
  183.                                     "toolTip":"Click this button to search in the current magazine"
  184.                                  };
  185.                               }
  186.                            }),new UIComponentDescriptor({
  187.                               "type":RadioButton,
  188.                               "id":"searchInArchive",
  189.                               "events":{"click":"__searchInArchive_click"},
  190.                               "propertiesFactory":function():Object
  191.                               {
  192.                                  return {
  193.                                     "buttonMode":true,
  194.                                     "styleName":"searchRadioButton",
  195.                                     "label":"In the whole archive",
  196.                                     "groupName":"searchgroup",
  197.                                     "toolTip":"Click this button to search all the magazines - takes longer"
  198.                                  };
  199.                               }
  200.                            }),new UIComponentDescriptor({
  201.                               "type":Text,
  202.                               "id":"resultsCount",
  203.                               "propertiesFactory":function():Object
  204.                               {
  205.                                  return {
  206.                                     "visible":false,
  207.                                     "width":160
  208.                                  };
  209.                               }
  210.                            }),new UIComponentDescriptor({
  211.                               "type":VBox,
  212.                               "id":"_VBox2",
  213.                               "stylesFactory":function():void
  214.                               {
  215.                                  this.backgroundColor = 14277081;
  216.                               },
  217.                               "propertiesFactory":function():Object
  218.                               {
  219.                                  return {
  220.                                     "width":188,
  221.                                     "height":675,
  222.                                     "horizontalScrollPolicy":"off",
  223.                                     "verticalLineScrollSize":10,
  224.                                     "childDescriptors":[new UIComponentDescriptor({
  225.                                        "type":Repeater,
  226.                                        "id":"searchRpt",
  227.                                        "propertiesFactory":function():Object
  228.                                        {
  229.                                           return {"childDescriptors":[new UIComponentDescriptor({
  230.                                              "type":Text,
  231.                                              "id":"rptText",
  232.                                              "events":{
  233.                                                 "rollOver":"__rptText_rollOver",
  234.                                                 "rollOut":"__rptText_rollOut",
  235.                                                 "click":"__rptText_click"
  236.                                              },
  237.                                              "propertiesFactory":function():Object
  238.                                              {
  239.                                                 return {
  240.                                                    "buttonMode":true,
  241.                                                    "selectable":false,
  242.                                                    "styleName":"resultOut"
  243.                                                 };
  244.                                              }
  245.                                           })]};
  246.                                        }
  247.                                     })]
  248.                                  };
  249.                               }
  250.                            })]
  251.                         };
  252.                      }
  253.                   }),new UIComponentDescriptor({
  254.                      "type":VBox,
  255.                      "id":"searchingBox",
  256.                      "stylesFactory":function():void
  257.                      {
  258.                         this.horizontalAlign = "center";
  259.                      },
  260.                      "propertiesFactory":function():Object
  261.                      {
  262.                         return {
  263.                            "x":6,
  264.                            "y":48,
  265.                            "visible":false,
  266.                            "childDescriptors":[new UIComponentDescriptor({
  267.                               "type":ProgressBar,
  268.                               "id":"progress",
  269.                               "propertiesFactory":function():Object
  270.                               {
  271.                                  return {
  272.                                     "indeterminate":true,
  273.                                     "label":"Searching",
  274.                                     "width":160
  275.                                  };
  276.                               }
  277.                            }),new UIComponentDescriptor({
  278.                               "type":Button,
  279.                               "id":"cancelBtn",
  280.                               "events":{"click":"__cancelBtn_click"},
  281.                               "propertiesFactory":function():Object
  282.                               {
  283.                                  return {
  284.                                     "styleName":"cancelBtn",
  285.                                     "label":"Cancel"
  286.                                  };
  287.                               }
  288.                            })]
  289.                         };
  290.                      }
  291.                   })]
  292.                };
  293.             }
  294.          });
  295.          _710473164searchTerm = "";
  296.          searchMode = "magazine";
  297.          dir = "data/text/";
  298.          ext = ".txt";
  299.          currentResult = 0;
  300.          _embed_mxml____embedded_assets_search_tab_bg_png_2045520245 = SearchTab__embed_mxml____embedded_assets_search_tab_bg_png_2045520245;
  301.          super();
  302.          mx_internal::_document = this;
  303.          this.width = 206;
  304.          this.height = 926;
  305.          this.verticalScrollPolicy = "off";
  306.          this.horizontalScrollPolicy = "off";
  307.          this.addEventListener("creationComplete",___Canvas1_creationComplete);
  308.       }
  309.       
  310.       public static function set watcherSetupUtil(param1:IWatcherSetupUtil) : void
  311.       {
  312.          SearchTab._watcherSetupUtil = param1;
  313.       }
  314.       
  315.       public function __searchInArchive_click(param1:MouseEvent) : void
  316.       {
  317.          searchRadioChangeHandler(param1);
  318.       }
  319.       
  320.       private function message(param1:String) : void
  321.       {
  322.          Alert.show(param1,"Hint");
  323.       }
  324.       
  325.       public function prevResult() : void
  326.       {
  327.          --currentResult;
  328.          if(0 <= currentResult)
  329.          {
  330.             showResult(searchResults.getItemAt(currentResult));
  331.          }
  332.          else
  333.          {
  334.             currentResult = 0;
  335.          }
  336.       }
  337.       
  338.       private function searchFocusInHandler(param1:Event) : void
  339.       {
  340.          if("search for..." == searchTxtInput.text)
  341.          {
  342.             searchTxtInput.text = "";
  343.          }
  344.       }
  345.       
  346.       [Bindable(event="propertyChange")]
  347.       public function get rptText() : Array
  348.       {
  349.          return this._1412401219rptText;
  350.       }
  351.       
  352.       private function fileStart(param1:SearchEvent) : void
  353.       {
  354.          var _loc2_:String = null;
  355.          var _loc3_:RegExp = null;
  356.          var _loc4_:String = null;
  357.          var _loc5_:String = null;
  358.          _loc2_ = param1.eventData.toString();
  359.          _loc3_ = /data\/text\/([0-9]+)\/([0-9]+)\s([A-Za-z]+)\s([0-9]+)\.txt/gi;
  360.          _loc4_ = _loc2_.replace(_loc3_,"$3");
  361.          _loc5_ = _loc2_.replace(_loc3_,"$1");
  362.          progress.label = "Searching " + _loc4_ + " " + _loc5_;
  363.       }
  364.       
  365.       [Bindable(event="propertyChange")]
  366.       public function get _VBox2() : VBox
  367.       {
  368.          return this._1493698498_VBox2;
  369.       }
  370.       
  371.       public function set progress(param1:ProgressBar) : void
  372.       {
  373.          var _loc2_:Object = null;
  374.          _loc2_ = this._1001078227progress;
  375.          if(_loc2_ !== param1)
  376.          {
  377.             this._1001078227progress = param1;
  378.             dispatchEvent(PropertyChangeEvent.createUpdateEvent(this,"progress",_loc2_,param1));
  379.          }
  380.       }
  381.       
  382.       public function set searchingBox(param1:VBox) : void
  383.       {
  384.          var _loc2_:Object = null;
  385.          _loc2_ = this._744247857searchingBox;
  386.          if(_loc2_ !== param1)
  387.          {
  388.             this._744247857searchingBox = param1;
  389.             dispatchEvent(PropertyChangeEvent.createUpdateEvent(this,"searchingBox",_loc2_,param1));
  390.          }
  391.       }
  392.       
  393.       private function searchFocusOutHandler(param1:Event) : void
  394.       {
  395.          if("" == searchTxtInput.text)
  396.          {
  397.             searchTxtInput.text = "search for...";
  398.          }
  399.       }
  400.       
  401.       private function set searchTerm(param1:String) : void
  402.       {
  403.          var _loc2_:Object = null;
  404.          _loc2_ = this._710473164searchTerm;
  405.          if(_loc2_ !== param1)
  406.          {
  407.             this._710473164searchTerm = param1;
  408.             dispatchEvent(PropertyChangeEvent.createUpdateEvent(this,"searchTerm",_loc2_,param1));
  409.          }
  410.       }
  411.       
  412.       public function set rptText(param1:Array) : void
  413.       {
  414.          var _loc2_:Object = null;
  415.          _loc2_ = this._1412401219rptText;
  416.          if(_loc2_ !== param1)
  417.          {
  418.             this._1412401219rptText = param1;
  419.             dispatchEvent(PropertyChangeEvent.createUpdateEvent(this,"rptText",_loc2_,param1));
  420.          }
  421.       }
  422.       
  423.       public function set presentationModel(param1:PresentationModel) : void
  424.       {
  425.          var _loc2_:Object = null;
  426.          _loc2_ = this._1857328081presentationModel;
  427.          if(_loc2_ !== param1)
  428.          {
  429.             this._1857328081presentationModel = param1;
  430.             dispatchEvent(PropertyChangeEvent.createUpdateEvent(this,"presentationModel",_loc2_,param1));
  431.          }
  432.       }
  433.       
  434.       [Bindable(event="propertyChange")]
  435.       public function get presentationModel() : PresentationModel
  436.       {
  437.          return this._1857328081presentationModel;
  438.       }
  439.       
  440.       public function set _VBox2(param1:VBox) : void
  441.       {
  442.          var _loc2_:Object = null;
  443.          _loc2_ = this._1493698498_VBox2;
  444.          if(_loc2_ !== param1)
  445.          {
  446.             this._1493698498_VBox2 = param1;
  447.             dispatchEvent(PropertyChangeEvent.createUpdateEvent(this,"_VBox2",_loc2_,param1));
  448.          }
  449.       }
  450.       
  451.       private function startSearch() : void
  452.       {
  453.          var _loc1_:Array = null;
  454.          _loc1_ = _makeFileList();
  455.          trace("will search in " + _loc1_.length + " files");
  456.          txtSearch.addEventListener(SearchEvent.FILE_START,fileStart);
  457.          if(false == txtSearch.searchFor(searchTerm,_loc1_))
  458.          {
  459.             trace("Could not start search");
  460.             searchInMag.selected = false;
  461.             searchInArchive.selected = false;
  462.             Alert.show("There was a problem searching - some common words may be ignored so please try again.");
  463.             return;
  464.          }
  465.          searchResults = null;
  466.          resultsCount.text = "";
  467.          searchBox.visible = false;
  468.          searchingBox.visible = true;
  469.       }
  470.       
  471.       private function rollOutHandler(param1:Event) : void
  472.       {
  473.          if(param1.target.repeaterIndex != currentResult)
  474.          {
  475.             param1.currentTarget.styleName = "resultOut";
  476.          }
  477.       }
  478.       
  479.       public function __cancelBtn_click(param1:MouseEvent) : void
  480.       {
  481.          cancelHandler(param1);
  482.       }
  483.       
  484.       private function clickHandler(param1:Event) : void
  485.       {
  486.          var _loc2_:* = undefined;
  487.          currentResult = param1.currentTarget.repeaterIndex;
  488.          _loc2_ = param1.currentTarget.getRepeaterItem();
  489.          trace("searchResult item " + _loc2_);
  490.          showResult(_loc2_);
  491.       }
  492.       
  493.       private function searchCancelled(param1:SearchEvent) : void
  494.       {
  495.          txtSearch.removeEventListener(SearchEvent.FILE_START,fileStart);
  496.          searchInMag.selected = false;
  497.          searchInArchive.selected = false;
  498.          searchingBox.visible = false;
  499.          searchBox.visible = true;
  500.       }
  501.       
  502.       private function searchRadioChangeHandler(param1:Event) : void
  503.       {
  504.          var _loc2_:String = null;
  505.          trace("search Radio changed " + param1.target + " - " + presentationModel.numPages);
  506.          if(param1.target == searchInArchive)
  507.          {
  508.             searchMode = "archive";
  509.          }
  510.          else
  511.          {
  512.             searchMode = "magazine";
  513.             if(-1 == presentationModel.numPages)
  514.             {
  515.                trace("-1 == numPages");
  516.                message("Use \'Browse By Cover\' to choose a magazine or search the whole archive.");
  517.                return;
  518.             }
  519.          }
  520.          searchTerm = searchTxtInput.text;
  521.          _loc2_ = searchTerm.replace(/[\W]/gi,"");
  522.          if(0 == searchTerm.length || 0 == _loc2_.length || "search for..." == searchTerm)
  523.          {
  524.             searchInMag.selected = false;
  525.             searchInArchive.selected = false;
  526.             Alert.show("Please enter a search phrase containing letters and/or numbers and try again");
  527.             return;
  528.          }
  529.          startSearch();
  530.       }
  531.       
  532.       [Bindable(event="propertyChange")]
  533.       public function get searchTxtInput() : TextInput
  534.       {
  535.          return this._682052866searchTxtInput;
  536.       }
  537.       
  538.       public function nextResult() : void
  539.       {
  540.          ++currentResult;
  541.          if(searchResults.length - 1 >= currentResult)
  542.          {
  543.             showResult(searchResults.getItemAt(currentResult));
  544.          }
  545.          else
  546.          {
  547.             currentResult = searchResults.length - 1;
  548.          }
  549.       }
  550.       
  551.       [Bindable(event="propertyChange")]
  552.       public function get searchInMag() : RadioButton
  553.       {
  554.          return this._559758042searchInMag;
  555.       }
  556.       
  557.       [Bindable(event="propertyChange")]
  558.       public function get searchResults() : ArrayCollection
  559.       {
  560.          return this._1880932050searchResults;
  561.       }
  562.       
  563.       private function _SearchTab_bindingsSetup() : void
  564.       {
  565.          var binding:Binding = null;
  566.          if(!_bindings)
  567.          {
  568.             _bindings = [];
  569.          }
  570.          if(!_watchers)
  571.          {
  572.             _watchers = [];
  573.          }
  574.          binding = new Binding(this,function():Boolean
  575.          {
  576.             return -1 != presentationModel.numPages ? true : false;
  577.          },function(param1:Boolean):void
  578.          {
  579.             searchInMag.enabled = param1;
  580.          },"searchInMag.enabled");
  581.          _bindings[0] = binding;
  582.          binding = new Binding(this,function():Object
  583.          {
  584.             return searchResults;
  585.          },function(param1:Object):void
  586.          {
  587.             searchRpt.dataProvider = param1;
  588.          },"searchRpt.dataProvider");
  589.          _bindings[1] = binding;
  590.          binding = new RepeatableBinding(this,function(param1:Array, param2:Array):String
  591.          {
  592.             var _loc3_:* = undefined;
  593.             var _loc4_:* = undefined;
  594.             _loc3_ = formatText(searchRpt.mx_internal::getItemAt(param2[0]));
  595.             return _loc3_ == undefined ? null : String(_loc3_);
  596.          },function(param1:String, param2:Array):void
  597.          {
  598.             rptText[param2[0]].htmlText = param1;
  599.          },"rptText.htmlText");
  600.          _bindings[2] = binding;
  601.       }
  602.       
  603.       private function init() : void
  604.       {
  605.          txtSearch = new TextFileSearcher();
  606.          txtSearch.addEventListener(Event.COMPLETE,searchComplete);
  607.          txtSearch.addEventListener(SearchEvent.CANCELLED,searchCancelled);
  608.       }
  609.       
  610.       public function __searchInMag_click(param1:MouseEvent) : void
  611.       {
  612.          searchRadioChangeHandler(param1);
  613.       }
  614.       
  615.       public function set resultsCount(param1:Text) : void
  616.       {
  617.          var _loc2_:Object = null;
  618.          _loc2_ = this._1057894073resultsCount;
  619.          if(_loc2_ !== param1)
  620.          {
  621.             this._1057894073resultsCount = param1;
  622.             dispatchEvent(PropertyChangeEvent.createUpdateEvent(this,"resultsCount",_loc2_,param1));
  623.          }
  624.       }
  625.       
  626.       private function showResult(param1:Object) : void
  627.       {
  628.          var _loc2_:int = 0;
  629.          var _loc3_:Text = null;
  630.          trace("showResult " + currentResult);
  631.          _loc2_ = 0;
  632.          while(_loc2_ < searchResults.length)
  633.          {
  634.             _loc3_ = rptText[_loc2_];
  635.             if(_loc2_ == currentResult)
  636.             {
  637.                _loc3_.styleName = "resultOver";
  638.             }
  639.             else
  640.             {
  641.                _loc3_.styleName = "resultOut";
  642.             }
  643.             trace("selTxt " + _loc3_ + " at " + _loc2_ + " style " + _loc3_.styleName);
  644.             _loc2_++;
  645.          }
  646.          dispatchEvent(new NavigationEvent(NavigationEvent.SHOW_SEARCH_RESULT,param1,true,false));
  647.       }
  648.       
  649.       [Bindable(event="propertyChange")]
  650.       public function get cancelBtn() : Button
  651.       {
  652.          return this._476548482cancelBtn;
  653.       }
  654.       
  655.       public function __rptText_rollOut(param1:MouseEvent) : void
  656.       {
  657.          rollOutHandler(param1);
  658.       }
  659.       
  660.       public function __searchTxtInput_focusIn(param1:FocusEvent) : void
  661.       {
  662.          searchFocusInHandler(param1);
  663.       }
  664.       
  665.       private function formatText(param1:Object) : String
  666.       {
  667.          var _loc2_:String = null;
  668.          var _loc3_:String = null;
  669.          _loc3_ = formatPage(param1.page,param1.numPages,param1.twoPageBack);
  670.          return "<p><b>" + param1.month + " " + param1.year + "<br>page " + _loc3_ + " (x" + param1.count + ")</b></p>";
  671.       }
  672.       
  673.       public function simpleSearch(param1:String) : void
  674.       {
  675.          if(0 == param1.length)
  676.          {
  677.             searchInMag.selected = false;
  678.             searchInArchive.selected = false;
  679.             Alert.show("Please enter a search term and try again");
  680.             return;
  681.          }
  682.          searchTerm = searchTxtInput.text = param1;
  683.          searchMode = "magazine";
  684.          searchInMag.selected = true;
  685.          searchInArchive.selected = false;
  686.          startSearch();
  687.       }
  688.       
  689.       public function set searchBox(param1:VBox) : void
  690.       {
  691.          var _loc2_:Object = null;
  692.          _loc2_ = this._1778179843searchBox;
  693.          if(_loc2_ !== param1)
  694.          {
  695.             this._1778179843searchBox = param1;
  696.             dispatchEvent(PropertyChangeEvent.createUpdateEvent(this,"searchBox",_loc2_,param1));
  697.          }
  698.       }
  699.       
  700.       public function __searchTxtInput_focusOut(param1:FocusEvent) : void
  701.       {
  702.          searchFocusOutHandler(param1);
  703.       }
  704.       
  705.       private function _makeFileList() : Array
  706.       {
  707.          var _loc1_:Array = null;
  708.          var _loc2_:int = 0;
  709.          var _loc3_:int = 0;
  710.          var _loc4_:Object = null;
  711.          var _loc5_:String = null;
  712.          var _loc6_:ArrayCollection = null;
  713.          var _loc7_:int = 0;
  714.          var _loc8_:int = 0;
  715.          var _loc9_:Object = null;
  716.          _loc1_ = new Array();
  717.          if("magazine" == searchMode)
  718.          {
  719.             _loc1_.push(this.dir + presentationModel.yearString + "/" + presentationModel.filePrefix + this.ext);
  720.          }
  721.          else
  722.          {
  723.             _loc2_ = presentationModel.years.length;
  724.             _loc3_ = 0;
  725.             while(_loc3_ < _loc2_)
  726.             {
  727.                _loc4_ = presentationModel.years.getItemAt(_loc3_);
  728.                _loc5_ = _loc4_.value;
  729.                _loc6_ = _loc4_.issue;
  730.                _loc7_ = _loc6_.length;
  731.                _loc8_ = 0;
  732.                while(_loc8_ < _loc7_)
  733.                {
  734.                   _loc9_ = _loc6_.getItemAt(_loc8_);
  735.                   _loc1_.push(this.dir + _loc5_ + "/" + _loc9_.file + this.ext);
  736.                   _loc8_++;
  737.                }
  738.                _loc3_++;
  739.             }
  740.          }
  741.          return _loc1_;
  742.       }
  743.       
  744.       [Bindable(event="propertyChange")]
  745.       public function get progress() : ProgressBar
  746.       {
  747.          return this._1001078227progress;
  748.       }
  749.       
  750.       [Bindable(event="propertyChange")]
  751.       public function get searchingBox() : VBox
  752.       {
  753.          return this._744247857searchingBox;
  754.       }
  755.       
  756.       [Bindable(event="propertyChange")]
  757.       private function get searchTerm() : String
  758.       {
  759.          return this._710473164searchTerm;
  760.       }
  761.       
  762.       public function set searchTxtInput(param1:TextInput) : void
  763.       {
  764.          var _loc2_:Object = null;
  765.          _loc2_ = this._682052866searchTxtInput;
  766.          if(_loc2_ !== param1)
  767.          {
  768.             this._682052866searchTxtInput = param1;
  769.             dispatchEvent(PropertyChangeEvent.createUpdateEvent(this,"searchTxtInput",_loc2_,param1));
  770.          }
  771.       }
  772.       
  773.       public function set searchInArchive(param1:RadioButton) : void
  774.       {
  775.          var _loc2_:Object = null;
  776.          _loc2_ = this._973070101searchInArchive;
  777.          if(_loc2_ !== param1)
  778.          {
  779.             this._973070101searchInArchive = param1;
  780.             dispatchEvent(PropertyChangeEvent.createUpdateEvent(this,"searchInArchive",_loc2_,param1));
  781.          }
  782.       }
  783.       
  784.       public function set searchInMag(param1:RadioButton) : void
  785.       {
  786.          var _loc2_:Object = null;
  787.          _loc2_ = this._559758042searchInMag;
  788.          if(_loc2_ !== param1)
  789.          {
  790.             this._559758042searchInMag = param1;
  791.             dispatchEvent(PropertyChangeEvent.createUpdateEvent(this,"searchInMag",_loc2_,param1));
  792.          }
  793.       }
  794.       
  795.       public function set searchRpt(param1:Repeater) : void
  796.       {
  797.          var _loc2_:Object = null;
  798.          _loc2_ = this._1778195246searchRpt;
  799.          if(_loc2_ !== param1)
  800.          {
  801.             this._1778195246searchRpt = param1;
  802.             dispatchEvent(PropertyChangeEvent.createUpdateEvent(this,"searchRpt",_loc2_,param1));
  803.          }
  804.       }
  805.       
  806.       public function set searchResults(param1:ArrayCollection) : void
  807.       {
  808.          var _loc2_:Object = null;
  809.          _loc2_ = this._1880932050searchResults;
  810.          if(_loc2_ !== param1)
  811.          {
  812.             this._1880932050searchResults = param1;
  813.             dispatchEvent(PropertyChangeEvent.createUpdateEvent(this,"searchResults",_loc2_,param1));
  814.          }
  815.       }
  816.       
  817.       public function ___Canvas1_creationComplete(param1:FlexEvent) : void
  818.       {
  819.          init();
  820.       }
  821.       
  822.       [Bindable(event="propertyChange")]
  823.       public function get resultsCount() : Text
  824.       {
  825.          return this._1057894073resultsCount;
  826.       }
  827.       
  828.       public function __rptText_click(param1:MouseEvent) : void
  829.       {
  830.          clickHandler(param1);
  831.       }
  832.       
  833.       public function set cancelBtn(param1:Button) : void
  834.       {
  835.          var _loc2_:Object = null;
  836.          _loc2_ = this._476548482cancelBtn;
  837.          if(_loc2_ !== param1)
  838.          {
  839.             this._476548482cancelBtn = param1;
  840.             dispatchEvent(PropertyChangeEvent.createUpdateEvent(this,"cancelBtn",_loc2_,param1));
  841.          }
  842.       }
  843.       
  844.       [Bindable(event="propertyChange")]
  845.       public function get searchInArchive() : RadioButton
  846.       {
  847.          return this._973070101searchInArchive;
  848.       }
  849.       
  850.       private function searchComplete(param1:Event) : void
  851.       {
  852.          var _loc2_:Array = null;
  853.          var _loc3_:Array = null;
  854.          var _loc4_:RegExp = null;
  855.          var _loc5_:int = 0;
  856.          var _loc6_:int = 0;
  857.          var _loc7_:String = null;
  858.          var _loc8_:String = null;
  859.          var _loc9_:ArrayCollection = null;
  860.          var _loc10_:Object = null;
  861.          var _loc11_:int = 0;
  862.          var _loc12_:String = null;
  863.          var _loc13_:Array = null;
  864.          var _loc14_:int = 0;
  865.          var _loc15_:int = 0;
  866.          var _loc16_:Object = null;
  867.          var _loc17_:String = null;
  868.          var _loc18_:Object = null;
  869.          _loc2_ = txtSearch.results;
  870.          _loc3_ = new Array();
  871.          _loc4_ = /data\/text\/([0-9]+)\/([0-9]+)\s([A-Za-z]+)\s([0-9]+)\.txt/gi;
  872.          _loc5_ = int(_loc2_.length);
  873.          _loc6_ = 0;
  874.          _loc7_ = "";
  875.          _loc8_ = "";
  876.          trace("search Complete for " + _loc5_ + " files");
  877.          _loc11_ = 0;
  878.          while(_loc11_ < _loc5_)
  879.          {
  880.             _loc12_ = _loc2_[_loc11_].file;
  881.             _loc13_ = _loc2_[_loc11_].indexes;
  882.             if(null != _loc13_)
  883.             {
  884.                _loc14_ = int(_loc13_.length);
  885.                trace("file " + _loc12_ + " has " + _loc14_ + " results");
  886.                _loc15_ = 0;
  887.                while(_loc15_ < _loc14_)
  888.                {
  889.                   _loc16_ = _loc13_[_loc15_];
  890.                   _loc16_.year = _loc12_.replace(_loc4_,"$1");
  891.                   _loc16_.month = _loc12_.replace(_loc4_,"$3");
  892.                   _loc17_ = _loc12_.replace(_loc4_,"$2 $3 $4");
  893.                   if(_loc7_ != _loc16_.year)
  894.                   {
  895.                      _loc15_ = 0;
  896.                      while(_loc15_ < presentationModel.years.length)
  897.                      {
  898.                         _loc18_ = presentationModel.years.getItemAt(_loc15_);
  899.                         if(_loc16_.year == _loc18_.value)
  900.                         {
  901.                            _loc9_ = _loc18_.issue;
  902.                            _loc7_ = _loc16_.year;
  903.                            break;
  904.                         }
  905.                         _loc15_++;
  906.                      }
  907.                   }
  908.                   if(_loc8_ != _loc16_.month)
  909.                   {
  910.                      _loc15_ = 0;
  911.                      while(_loc15_ < _loc9_.length)
  912.                      {
  913.                         _loc18_ = _loc9_.getItemAt(_loc15_);
  914.                         if(_loc17_ == _loc18_.file)
  915.                         {
  916.                            _loc10_ = _loc18_;
  917.                            _loc8_ = _loc16_.month;
  918.                            break;
  919.                         }
  920.                         _loc15_++;
  921.                      }
  922.                   }
  923.                   _loc16_.numPages = _loc2_[_loc11_].numPages;
  924.                   _loc16_.twoPageBack = _loc10_.twoPageBack;
  925.                   _loc3_.push(_loc16_);
  926.                   _loc6_++;
  927.                   _loc15_++;
  928.                }
  929.             }
  930.             _loc11_++;
  931.          }
  932.          txtSearch.removeEventListener(SearchEvent.FILE_START,fileStart);
  933.          searchInMag.selected = false;
  934.          searchInArchive.selected = false;
  935.          searchBox.visible = true;
  936.          searchingBox.visible = false;
  937.          resultsCount.text = _loc6_ + " results";
  938.          resultsCount.visible = true;
  939.          currentResult = 0;
  940.          searchResults = new ArrayCollection(_loc3_);
  941.       }
  942.       
  943.       private function formatPage(param1:int, param2:int, param3:Boolean) : String
  944.       {
  945.          var _loc4_:* = null;
  946.          var _loc5_:int = 0;
  947.          if(-1 == param1 || -1 == param2)
  948.          {
  949.             return "";
  950.          }
  951.          _loc4_ = param1.toString();
  952.          if(0 == param1)
  953.          {
  954.             _loc4_ = "1";
  955.          }
  956.          else if(param1 == param2 - 1 && false == param3)
  957.          {
  958.             _loc4_ = param1 * 2 + "";
  959.          }
  960.          else
  961.          {
  962.             _loc5_ = param1 * 2;
  963.             _loc4_ = "" + _loc5_ + " & " + ++_loc5_;
  964.          }
  965.          return _loc4_;
  966.       }
  967.       
  968.       [Bindable(event="propertyChange")]
  969.       public function get searchRpt() : Repeater
  970.       {
  971.          return this._1778195246searchRpt;
  972.       }
  973.       
  974.       private function _SearchTab_bindingExprs() : void
  975.       {
  976.          var _loc1_:* = undefined;
  977.          _loc1_ = -1 != presentationModel.numPages ? true : false;
  978.          _loc1_ = searchResults;
  979.          _loc1_ = formatText(searchRpt.currentItem);
  980.       }
  981.       
  982.       [Bindable(event="propertyChange")]
  983.       public function get searchBox() : VBox
  984.       {
  985.          return this._1778179843searchBox;
  986.       }
  987.       
  988.       private function rollOverHandler(param1:Event) : void
  989.       {
  990.          param1.currentTarget.styleName = "resultOver";
  991.       }
  992.       
  993.       public function __rptText_rollOver(param1:MouseEvent) : void
  994.       {
  995.          rollOverHandler(param1);
  996.       }
  997.       
  998.       private function cancelHandler(param1:Event) : void
  999.       {
  1000.          txtSearch.cancel();
  1001.       }
  1002.       
  1003.       override public function initialize() : void
  1004.       {
  1005.          var target:SearchTab = null;
  1006.          var watcherSetupUtilClass:Object = null;
  1007.          mx_internal::setDocumentDescriptor(_documentDescriptor_);
  1008.          _SearchTab_bindingsSetup();
  1009.          target = this;
  1010.          if(_watcherSetupUtil == null)
  1011.          {
  1012.             watcherSetupUtilClass = getDefinitionByName("_views_SearchTabWatcherSetupUtil");
  1013.             watcherSetupUtilClass["init"](null);
  1014.          }
  1015.          _watcherSetupUtil.setup(this,function(param1:String):*
  1016.          {
  1017.             return target[param1];
  1018.          },_bindings,_watchers);
  1019.          super.initialize();
  1020.       }
  1021.    }
  1022. }
  1023.  
  1024.